package com.edu.exam.entity.examination.online.technical;

import com.edu.exam.enums.ScannerConnectionStatus;
import com.edu.exam.enums.ScannerConnectionType;
import com.edu.exam.enums.ScannerDeviceType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * 扫描仪设备实体类
 *
 * 根据E-04-01设备适配子模块设计实现
 * 存储扫描仪设备的基本信息和配置数据。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ScannerDevice {

    /**
     * 设备ID，主键
     */
    @Id
    @Column(name = "device_id", length = 64)
    private String deviceId;

    /**
     * 设备名称
     */
    @Column(name = "device_name", length = 128, nullable = false)
    private String deviceName;

    /**
     * 设备型号
     */
    @Column(name = "device_model", length = 128)
    private String deviceModel;

    /**
     * 制造商
     */
    @Column(name = "manufacturer", length = 64)
    private String manufacturer;

    /**
     * 设备类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "device_type", length = 32, nullable = false)
    private ScannerDeviceType deviceType;

    /**
     * 连接类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "connection_type", length = 32, nullable = false)
    private ScannerConnectionType connectionType;

    /**
     * 连接状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "connection_status", length = 32, nullable = false)
    private ScannerConnectionStatus connectionStatus;

    /**
     * 设备地址（IP地址、USB路径等）
     */
    @Column(name = "device_address", length = 256)
    private String deviceAddress;

    /**
     * 设备描述
     */
    @Column(name = "device_description", length = 512)
    private String deviceDescription;

    /**
     * 驱动信息
     */
    @Column(name = "driver_info", columnDefinition = "TEXT")
    private String driverInfo;

    /**
     * 设备能力信息
     */
    @Column(name = "capabilities", columnDefinition = "TEXT")
    private String capabilities;

    /**
     * 当前配置
     */
    @Column(name = "current_config", columnDefinition = "TEXT")
    private String currentConfig;

    /**
     * 设备优先级（数值越高优先级越高）
     */
    @Column(name = "priority_level")
    private Integer priorityLevel;

    /**
     * 是否启用
     */
    @Column(name = "is_enabled", nullable = false)
    private Boolean isEnabled;

    /**
     * 是否为默认设备
     */
    @Column(name = "is_default", nullable = false)
    private Boolean isDefault;

    /**
     * 最后连接时间
     */
    @Column(name = "last_connected_time")
    private LocalDateTime lastConnectedTime;

    /**
     * 最后断开时间
     */
    @Column(name = "last_disconnected_time")
    private LocalDateTime lastDisconnectedTime;

    /**
     * 总扫描页数
     */
    @Column(name = "total_scan_pages")
    private Long totalScanPages;

    /**
     * 故障次数
     */
    @Column(name = "failure_count")
    private Integer failureCount;

    /**
     * 维护备注
     */
    @Column(name = "maintenance_notes", columnDefinition = "TEXT")
    private String maintenanceNotes;

    /**
     * 创建人ID
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;


}